$(function() {
    src=''; 
    
    $('#life_chat').hover(
    	    function(){$(this).stop().animate({left:0}); },
    	    function(){$(this).stop().animate({left:-10});}
    	    );
    
    $('.warning').hide();
            
    $('#p2 a img').click(function(e)
    {      
        e.preventDefault();
        if (src != $(this).attr('longdesc')){ 
            src=$(this).attr('longdesc');                       
            $('.working').fadeOut(500,function()
            {                                                                        
                $(this).load(function(){
                    $(this).fadeIn()
                }).attr('src',src);
            });
        }                          
    });
    
     $('input, textarea').focus(function(){
        $(this).removeClass('no_warning');
            $(this).addClass('black_w');
    })
    
    $('input, textarea').blur(function(){
       $(this).removeClass('black_w');
            $(this).addClass('no_warning');
    })
    
   /////
            
    var width_menu = 157;
    var width_slide = 978;
              
    $('#links_menu li').each(function(i){
        $(this).attr({
            number: i
        });
    });
              
    $('#links_menu li').click(function(){
        var selected = $(this).attr('number');
        var margin_menu = selected * width_menu;
        var left_slide = selected * width_slide * -1;
        $('#active_link').animate({
            marginLeft: margin_menu
        },400);
        $('#lenta').css('left', left_slide+'px');
    });
              
              
    var slider_count = $('#slider li').length;
    var visible_slides = 4;
    var left_slide = 1;
              
    function check_arrows(slider_count, visible_slides, left_slide){
        if (left_slide<=slider_count-visible_slides) {
                                   
            $('#right_slide').removeClass('right_slide_no');
            $('#right_slide').addClass('right_slide_activ');
        } else {
                                    
            $('#right_slide').removeClass('right_slide_activ');
            $('#right_slide').addClass('right_slide_no');      				
        };
        			
        if (left_slide>1) {        			     
            $('#left_slide').removeClass('left_slide_no');
            $('#left_slide').addClass('left_slide_activ');
        } else {
                                    
            $('#left_slide').removeClass('left_slide_activ');
            $('#left_slide').addClass('left_slide_no');       				
        }	
    }
              
    $('#right_slide').click(function(){
        if (left_slide<=slider_count-visible_slides) {
            left_slide++;
            $('#slider').animate({
                marginLeft: '-=220'
            },800);
        }
        check_arrows(slider_count, visible_slides, left_slide);
    })
                
    $('#left_slide').click(function(){
        if (left_slide>1) {
            left_slide--;
            $('#slider').animate({
                marginLeft: '+=220'
            },800);
        }
        check_arrows(slider_count, visible_slides, left_slide);
    })

});